package cn.memedai.router.demo;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.multidex.MultiDexApplication;

import cn.memedai.router.RouteInterceptor;
import cn.memedai.router.Router;
import cn.memedai.router.annotation.Module;
import cn.memedai.router.annotation.Modules;

@Modules({"app", "appmodule"})
@Module("app")
public class App extends MultiDexApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        // debug模式,显示log
        Router.setDebuggable(true);
        Router.initialize(this);
        Router.addGlobalInterceptor(new RouteInterceptor() {
            @Override
            public boolean intercept(Context context, @NonNull Uri uri, @Nullable Bundle extras) {
                return false;
            }

            @Override
            public void intercepted(Context context, @NonNull Uri uri, @Nullable Bundle extras) {
                Toast.makeText(context, "Intercepted by GlobalInterceptor.", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
